﻿#region License
/*
Copyright (c) 2005-2008, CellAO Team

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the CellAO Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

#region Usings...
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.Text;
using Cell.Core;
using ZoneEngine.Database;
using ZoneEngine.Database.Items;
#endregion

namespace ZoneEngine.Packets
{
    public static class FullCharacter
    {
        #region WriteStat's
        private static void WriteStat3232(Client client, BinaryWriter m_writer, int statId)
        {
            /* Stat */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)statId));
            /* Value */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)client.Character.stats.GetStat(statId)));
        }

        private static void WriteStat3232(Client client, BinaryWriter m_writer, string statName)
        {
            WriteStat3232(client, m_writer, StatsList.GetStatId(statName));
        }

        private static void WriteStat816(Client client, BinaryWriter m_writer, int statId)
        {
            if (statId > 255)
                Console.WriteLine("WriteStat816 statId(" + statId + ") > 255");

            /* Stat */
            m_writer.Write((byte)statId);
            /* Value */
            m_writer.Write(IPAddress.HostToNetworkOrder((short)client.Character.stats.GetStat(statId)));
        }

        private static void WriteStat816(Client client, BinaryWriter m_writer, string statName)
        {
            WriteStat816(client, m_writer, StatsList.GetStatId(statName));
        }

        private static void WriteStat88(Client client, BinaryWriter m_writer, int statId)
        {
            if (statId > 255)
                Console.WriteLine("WriteStat88 statId(" + statId + ") > 255");
            /* Stat */
            m_writer.Write((byte)statId);
            /* Value */
            m_writer.Write((byte)client.Character.stats.GetStat(statId));
        }

        private static void WriteStat88(Client client, BinaryWriter m_writer, string statName)
        {
            WriteStat88(client, m_writer, StatsList.GetStatId(statName));
        }
        #endregion

        public static void Send(Client client)
        {
            MemoryStream m_stream = new MemoryStream();
            BinaryWriter m_writer = new BinaryWriter(m_stream);

            /* start writing packet */
            #region Header
            /* start of packet */
            m_writer.Write(new byte[] { 0xDF, 0xDF });
            /* packet type */
            m_writer.Write(IPAddress.HostToNetworkOrder((short)10));
            /* ? */
            m_writer.Write(IPAddress.HostToNetworkOrder((short)1));
            /* packet length (0 for now, taken care of later) */
            m_writer.Write(IPAddress.HostToNetworkOrder((short)0));
            /* sender ID (our server) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)3086));
            /* receiver ID */
            m_writer.Write(IPAddress.HostToNetworkOrder(client.Character.characterId));
            /* packet ID */
            m_writer.Write(new byte[] { 0x29, 0x30, 0x43, 0x49 });
            /* affected type */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)50000));
            /* affected ID */
            m_writer.Write(IPAddress.HostToNetworkOrder(client.Character.characterId));
            #endregion
            /* ? */
            m_writer.Write((byte)0);
            /* ? */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)21));

            #region Data01 (Inventory)
            /* part 1 of data */
            /* ((number of entries +1) * 1009) */
            List<ItemsEntry> m_items = ItemsList.LoadItems(client.Character.characterId);
            m_writer.Write(IPAddress.HostToNetworkOrder(((m_items.Count + 1) * 1009)));
            foreach (ItemsEntry m_item in m_items)
            {
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Placement));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Flags));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.MultipleCount));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Type));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Instance));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.LowID));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.HighID));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Quality));
                m_writer.Write(IPAddress.HostToNetworkOrder(m_item.Nothing));
            }
            #endregion
            #region Data02 (Uploaded nanos)
            /* part 2 of data */
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data03 (Empty)
            /* part 3 of data */
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data04 (Skill locks)
            /* Int32 Skill ID, Int32 Remaining time (milliseconds probably) */
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data05 (Empty)
            /* part 5 of data */
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data06 (Stats 1) (32bit - 32bit)
            /* part 6 of data (1-st stats block) */
            
            /* Int32 stat number
               Int32 stat value */
            
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((62 + 1) * 1009)));

            /* State */
            WriteStat3232(client, m_writer, 7);
            
            /* UnarmedTemplateInstance */
            WriteStat3232(client, m_writer, 418);
            
            /* Invaders Killed */
            WriteStat3232(client, m_writer, 615);
            
            /* KilledByInvaders */
            WriteStat3232(client, m_writer, 616);

            /* AccountFlags */
            WriteStat3232(client, m_writer, 660);

            /* VP */
            WriteStat3232(client, m_writer, 669);

            /* UnsavedXP */
            WriteStat3232(client, m_writer, 592);

            /* NanoFocusLevel */
            WriteStat3232(client, m_writer, 355);

            /* Specialization */
            WriteStat3232(client, m_writer, 182);

            /* ShadowBreedTemplate */
            WriteStat3232(client, m_writer, 579);

            /* ShadowBreed */
            WriteStat3232(client, m_writer, 532);

            /* LastPerkResetTime */
            WriteStat3232(client, m_writer, 577);

            /* SocialStatus */
            WriteStat3232(client, m_writer, 521);

            /* PlayerOptions */
            WriteStat3232(client, m_writer, 576);

            /* TempSaveTeamID */
            WriteStat3232(client, m_writer, 594);

            /* TempSavePlayfield */
            WriteStat3232(client, m_writer, 595);

            /* TempSaveX */
            WriteStat3232(client, m_writer, 596);

            /* TempSaveY */
            WriteStat3232(client, m_writer, 597);

            /* VisualFlags */
            WriteStat3232(client, m_writer, 673);

            /* PvPDuelKills */
            WriteStat3232(client, m_writer, 674);

            /* PvPDuelDeaths */
            WriteStat3232(client, m_writer, 675);

            /* PvPProfessionDuelKills */
            WriteStat3232(client, m_writer, 676);

            /* PvPProfessionDuelDeaths */
            WriteStat3232(client, m_writer, 677);

            /* PvPRankedSoloKills */
            WriteStat3232(client, m_writer, 678);

            /* PvPRankedSoloDeaths */
            WriteStat3232(client, m_writer, 679);

            /* PvPRankedTeamKills */
            WriteStat3232(client, m_writer, 680);

            /* PvPRankedTeamDeaths */
            WriteStat3232(client, m_writer, 681);

            /* PvPSoloScore */
            WriteStat3232(client, m_writer, 682);

            /* PvPTeamScore */
            WriteStat3232(client, m_writer, 683);

            /* PvPDuelScore */
            WriteStat3232(client, m_writer, 684);

            /* SavedXP */
            WriteStat3232(client, m_writer, 334);

            /* Flags */
            WriteStat3232(client, m_writer, 0);

            /* Features */
            WriteStat3232(client, m_writer, 224);

            /* ApartmentsAllowed */
            WriteStat3232(client, m_writer, 582);

            /* ApartmentsOwned */
            WriteStat3232(client, m_writer, 583);

            /* MonsterScale */
            WriteStat3232(client, m_writer, 360);

            /* VisualProfession */
            WriteStat3232(client, m_writer, 368);

            /* NanoAC */
            WriteStat3232(client, m_writer, 168);

            /* LastConcretePlayfieldInstance */
            WriteStat3232(client, m_writer, 191);

            /* MapOptions */
            WriteStat3232(client, m_writer, 470);

            /* MapAreaPart1 */
            WriteStat3232(client, m_writer, 471);

            /* MapAreaPart2 */
            WriteStat3232(client, m_writer, 472);

            /* MapAreaPart3 */
            WriteStat3232(client, m_writer, 585);

            /* MapAreaPart4 */
            WriteStat3232(client, m_writer, 586);

            /* MissionBits1 */
            WriteStat3232(client, m_writer, 256);

            /* MissionBits2 */
            WriteStat3232(client, m_writer, 257);

            /* MissionBits3 */
            WriteStat3232(client, m_writer, 303);

            /* MissionBits4 */
            WriteStat3232(client, m_writer, 432);

            /* MissionBits5 */
            WriteStat3232(client, m_writer, 65);

            /* MissionBits6 */
            WriteStat3232(client, m_writer, 66);

            /* MissionBits7 */
            WriteStat3232(client, m_writer, 67);

            /* MissionBits8 */
            WriteStat3232(client, m_writer, 544);

            /* MissionBits9 */
            WriteStat3232(client, m_writer, 545);

            /* MissionBits10 */
            WriteStat3232(client, m_writer, 617);

            /* AutoAttackFlags */
            WriteStat3232(client, m_writer, 349);

            /* PersonalResearchLevel */
            WriteStat3232(client, m_writer, 263);

            /* GlobalResearchLevel */
            WriteStat3232(client, m_writer, 264);

            /* PersonalResearchGoal */
            WriteStat3232(client, m_writer, 265);

            /* GlobalResearchGoal */
            WriteStat3232(client, m_writer, 266);

            /* BattlestationSide */
            WriteStat3232(client, m_writer, 668);

            /* BattlestationRep */
            WriteStat3232(client, m_writer, 670);

            /* Members */
            WriteStat3232(client, m_writer, 300);
            #endregion
            #region Data07 (Stats 2) (32bit - 32bit)
            /* ((number of entries + 1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((144 + 1) * 1009)));

            /* Int32 stat number
               Int32 stat value */

            /* VeteranPoints */
            WriteStat3232(client, m_writer, 68);

            /* MonthsPaid */
            WriteStat3232(client, m_writer, 69);

            /* PaidPoints */
            WriteStat3232(client, m_writer, 672);

            /* AutoAttackFlags */
            WriteStat3232(client, m_writer, 349);

            /* XPKillRange */
            WriteStat3232(client, m_writer, 275);

            /* InPlay */
            WriteStat3232(client, m_writer, 194);

            /* Health (current health)*/
            WriteStat3232(client, m_writer, 27);

            /* Life (max health)*/
            WriteStat3232(client, m_writer, 1);

            /* Psychic */
            WriteStat3232(client, m_writer, 21);

            /* Sense */
            WriteStat3232(client, m_writer, 20);

            /* Intelligence */
            WriteStat3232(client, m_writer, 19);

            /* Stamina */
            WriteStat3232(client, m_writer, 18);

            /* Agility */
            WriteStat3232(client, m_writer, 17);

            /* Strength */
            WriteStat3232(client, m_writer, 16);

            /* Attitude */
            WriteStat3232(client, m_writer, 63);

            /* Alignment (Clan Tokens) */
            WriteStat3232(client, m_writer, 62);

            /* Cash */
            WriteStat3232(client, m_writer, 61);

            /* Profession */
            WriteStat3232(client, m_writer, 60);

            /* AggDef */
            WriteStat3232(client, m_writer, 51);

            /* Icon */
            WriteStat3232(client, m_writer, 79);

            /* Mesh */
            WriteStat3232(client, m_writer, 12);

            /* RunSpeed */
            WriteStat3232(client, m_writer, 156);

            /* DeadTimer */
            WriteStat3232(client, m_writer, 34);

            /* Team */
            WriteStat3232(client, m_writer, 6);

            /* Breed */
            WriteStat3232(client, m_writer, 4);

            /* Sex */
            WriteStat3232(client, m_writer, 59);

            /* LastSaveXP */
            WriteStat3232(client, m_writer, 372);

            /* NextXP */
            WriteStat3232(client, m_writer, 350);

            /* LastXP */
            WriteStat3232(client, m_writer, 57);

            /* Level */
            WriteStat3232(client, m_writer, 54);

            /* XP */
            WriteStat3232(client, m_writer, 52);

            /* IP */
            WriteStat3232(client, m_writer, 53);

            /* CurrentMass */
            WriteStat3232(client, m_writer, 78);

            /* ItemType */
            WriteStat3232(client, m_writer, 72);

            /* PreviousHealth */
            WriteStat3232(client, m_writer, 11);

            /* CurrentState */
            WriteStat3232(client, m_writer, 423);

            /* Age */
            WriteStat3232(client, m_writer, 58);

            /* Side */
            WriteStat3232(client, m_writer, 33);

            /* WaitState */
            WriteStat3232(client, m_writer, 430);

            /* DriveWater */
            WriteStat3232(client, m_writer, 117);

            /* MeleeMultiple */
            WriteStat3232(client, m_writer, 101);

            /* LR_MultipleWeapon */
            WriteStat3232(client, m_writer, 134);

            /* LR_EnergyWeapon */
            WriteStat3232(client, m_writer, 133);

            /* RadiationAC */
            WriteStat3232(client, m_writer, 94);

            /* SenseImprovement */
            WriteStat3232(client, m_writer, 122);

            /* BowSpecialAttack */
            WriteStat3232(client, m_writer, 121);

            /* Burst */
            WriteStat3232(client, m_writer, 148);

            /* FullAuto */
            WriteStat3232(client, m_writer, 167);

            /* MapNavigation */
            WriteStat3232(client, m_writer, 140);

            /* DriveAir */
            WriteStat3232(client, m_writer, 139);

            /* DriveGround */
            WriteStat3232(client, m_writer, 166);

            /* BreakingEntry */
            WriteStat3232(client, m_writer, 165);

            /* Concealment */
            WriteStat3232(client, m_writer, 164);

            /* Chemistry */
            WriteStat3232(client, m_writer, 163);

            /* Psychology */
            WriteStat3232(client, m_writer, 162);

            /* ComputerLiteracy */
            WriteStat3232(client, m_writer, 161);

            /* NanoProgramming */
            WriteStat3232(client, m_writer, 160);

            /* Pharmaceuticals */
            WriteStat3232(client, m_writer, 159);

            /* WeaponSmithing */
            WriteStat3232(client, m_writer, 158);

            /* FieldQuantumPhysics */
            WriteStat3232(client, m_writer, 157);

            /* AttackSpeed */
            WriteStat3232(client, m_writer, 3);

            /* Evade */
            WriteStat3232(client, m_writer, 155);

            /* Dodge */
            WriteStat3232(client, m_writer, 154);

            /* Duck */
            WriteStat3232(client, m_writer, 153);

            /* BodyDevelopment */
            WriteStat3232(client, m_writer, 152);

            /* AimedShot */
            WriteStat3232(client, m_writer, 151);

            /* FlingShot */
            WriteStat3232(client, m_writer, 150);

            /* NanoProwessInitiative */
            WriteStat3232(client, m_writer, 149);

            /* FastAttack */
            WriteStat3232(client, m_writer, 147);

            /* SneakAttack */
            WriteStat3232(client, m_writer, 146);

            /* Parry */
            WriteStat3232(client, m_writer, 145);

            /* Dimach */
            WriteStat3232(client, m_writer, 144);

            /* Riposte */
            WriteStat3232(client, m_writer, 143);

            /* Brawl */
            WriteStat3232(client, m_writer, 142);

            /* Tutoring */
            WriteStat3232(client, m_writer, 141);

            /* Swim */
            WriteStat3232(client, m_writer, 138);

            /* Adventuring */
            WriteStat3232(client, m_writer, 137);

            /* Perception */
            WriteStat3232(client, m_writer, 136);

            /* DisarmTraps */
            WriteStat3232(client, m_writer, 135);

            /* NanoEnergyPool */
            WriteStat3232(client, m_writer, 132);

            /* MaterialLocation */
            WriteStat3232(client, m_writer, 131);

            /* MaterialCreation */
            WriteStat3232(client, m_writer, 130);

            /* PsychologicalModification */
            WriteStat3232(client, m_writer, 129);

            /* BiologicalMetamorphose */
            WriteStat3232(client, m_writer, 128);

            /* MaterialMetamorphose */
            WriteStat3232(client, m_writer, 127);

            /* ElectricalEngineering */
            WriteStat3232(client, m_writer, 126);

            /* MechanicalEngineering */
            WriteStat3232(client, m_writer, 125);

            /* Treatment */
            WriteStat3232(client, m_writer, 124);

            /* FirstAid */
            WriteStat3232(client, m_writer, 123);

            /* PhysicalProwessInitiative */
            WriteStat3232(client, m_writer, 120);

            /* DistanceWeaponInitiative */
            WriteStat3232(client, m_writer, 119);

            /* CloseCombatInitiative */
            WriteStat3232(client, m_writer, 118);

            /* AssaultRifle */
            WriteStat3232(client, m_writer, 116);

            /* Shotgun */
            WriteStat3232(client, m_writer, 115);

            /* SubMachineGun */
            WriteStat3232(client, m_writer, 114);

            /* Rifle */
            WriteStat3232(client, m_writer, 113);

            /* Pistol */
            WriteStat3232(client, m_writer, 112);

            /* Bow */
            WriteStat3232(client, m_writer, 111);

            /* ThrownGrapplingWeapons */
            WriteStat3232(client, m_writer, 110);

            /* Grenade */
            WriteStat3232(client, m_writer, 109);

            /* ThrowingKnife */
            WriteStat3232(client, m_writer, 108);

            /* 2HBluntWeapons */
            WriteStat3232(client, m_writer, 107);

            /* Piercing */
            WriteStat3232(client, m_writer, 106);

            /* 2HEdgedWeapons */
            WriteStat3232(client, m_writer, 105);

            /* MeleeEnergyWeapon */
            WriteStat3232(client, m_writer, 104);

            /* 1HEdgedWeapons */
            WriteStat3232(client, m_writer, 103);

            /* 1HBluntWeapons */
            WriteStat3232(client, m_writer, 102);

            /* MartialArts */
            WriteStat3232(client, m_writer, 100);

            /* Alignment (Clan Tokens) */
            WriteStat3232(client, m_writer, 62);

            /* MetaType (Omni Tokens) */
            WriteStat3232(client, m_writer, 75);

            /* TitleLevel */
            WriteStat3232(client, m_writer, 37);

            /* GmLevel */
            WriteStat3232(client, m_writer, 215);

            /* FireAC */
            WriteStat3232(client, m_writer, 97);

            /* PoisonAC */
            WriteStat3232(client, m_writer, 96);

            /* ColdAC */
            WriteStat3232(client, m_writer, 95);

            /* RadiationAC */
            WriteStat3232(client, m_writer, 94);

            /* ChemicalAC */
            WriteStat3232(client, m_writer, 93);

            /* EnergyAC */
            WriteStat3232(client, m_writer, 92);

            /* MeleeAC */
            WriteStat3232(client, m_writer, 91);

            /* ProjectileAC */
            WriteStat3232(client, m_writer, 90);

            /* RP */
            WriteStat3232(client, m_writer, 199);

            /* SpecialCondition */
            WriteStat3232(client, m_writer, 348);

            /* SK */
            WriteStat3232(client, m_writer, 573);

            /* Expansions */
            WriteStat3232(client, m_writer, 389);

            /* ClanRedeemed */
            WriteStat3232(client, m_writer, 572);

            /* ClanConserver */
            WriteStat3232(client, m_writer, 571);

            /* ClanDevoted */
            WriteStat3232(client, m_writer, 570);

            /* OTUnredeemed */
            WriteStat3232(client, m_writer, 569);

            /* OTOperator */
            WriteStat3232(client, m_writer, 568);

            /* OTFollowers */
            WriteStat3232(client, m_writer, 567);

            /* GOS */
            WriteStat3232(client, m_writer, 566);

            /* ClanVanguards */
            WriteStat3232(client, m_writer, 565);

            /* OTTrans */
            WriteStat3232(client, m_writer, 564);

            /* ClanGaia */
            WriteStat3232(client, m_writer, 563);

            /* OTMed*/
            WriteStat3232(client, m_writer, 562);

            /* ClanSentinels */
            WriteStat3232(client, m_writer, 561);

            /* OTArmedForces */
            WriteStat3232(client, m_writer, 560);

            /* SocialStatus */
            WriteStat3232(client, m_writer, 521);

            /* PlayerID */
            WriteStat3232(client, m_writer, 607);

            /* KilledByInvaders */
            WriteStat3232(client, m_writer, 616);

            /* InvadersKilled */
            WriteStat3232(client, m_writer, 615);

            /* AlienLevel */
            WriteStat3232(client, m_writer, 169);

            /* AlienNextXP */
            WriteStat3232(client, m_writer, 178);

            /* AlienXP */
            WriteStat3232(client, m_writer, 40);
            #endregion
            #region Data08 (Stats 3) (8bit - 8bit)
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((8 + 1) * 1009)));

            /* Byte stat number
               Byte stat value */

            /* InsurancePercentage */
            WriteStat88(client, m_writer, 236);

            /* ProfessionLevel */
            WriteStat88(client, m_writer, 10);

            /* PrevMovementMode */
            WriteStat88(client, m_writer, 174);

            /* CurrentMovementMode */
            WriteStat88(client, m_writer, 173);

            /* Fatness */
            WriteStat88(client, m_writer, 47);

            /* Race */
            WriteStat88(client, m_writer, 89);

            /* TeamSide */
            WriteStat88(client, m_writer, 213);

            /* BeltSlots */
            WriteStat88(client, m_writer, 45);
            #endregion
            #region Data09 (Stats 4) (8bit - 16bit)
            /* ((number of stats + 1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((16 + 1) * 1009)));

            /* Byte stat number
               Int16 (short) stat value */

            /* AbsorbProjectileAC */
            WriteStat816(client, m_writer, 238);

            /* AbsorbMeleeAC */
            WriteStat816(client, m_writer, 239);

            /* AbsorbEnergyAC */
            WriteStat816(client, m_writer, 240);

            /* AbsorbChemicalAC */
            WriteStat816(client, m_writer, 241);

            /* AbsorbRadiationAC */
            WriteStat816(client, m_writer, 242);

            /* AbsorbColdAC */
            WriteStat816(client, m_writer, 243);

            /* AbsorbNanoAC */
            WriteStat816(client, m_writer, 246);

            /* AbsorbFireAC */
            WriteStat816(client, m_writer, 244);

            /* AbsorbPoisonAC */
            WriteStat816(client, m_writer, 245);

            /* TemporarySkillReduction */
            WriteStat816(client, m_writer, 247);

            /* InsuranceTime */
            WriteStat816(client, m_writer, 49);

            /* CurrentNano */
            WriteStat816(client, m_writer, 214);

            /* MaxNanoEnergy */
            WriteStat816(client, m_writer, 221);

            /* MaxNCU */
            WriteStat816(client, m_writer, 181);

            /* MapFlags */
            WriteStat816(client, m_writer, 9);

            /* ChangeSideCount */
            WriteStat816(client, m_writer, 237);
            #endregion
            /* ? */
            m_writer.Write((int)0);
            /* ? */
            m_writer.Write((int)0);
            #region Data10 (Empty)
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data11 (Empty)
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion
            #region Data12 (Empty)
            /* ((number of entries +1) * 1009) */
            m_writer.Write(IPAddress.HostToNetworkOrder((int)((0 + 1) * 1009)));
            #endregion

            m_writer.Flush();
            m_stream.Capacity = (int)m_stream.Length;
            byte[] reply = m_stream.GetBuffer();
            m_writer.Close();
            m_stream.Dispose();
            byte[] reply_length = BitConverter.GetBytes(reply.Length);
            reply[6] = reply_length[1];
            reply[7] = reply_length[0];
            client.CmpStream.Write(reply, 0, reply.Length);
            client.CmpStream.Flush();
        }
    }
}
